﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace EcodexIntegrationSample.Forms
{
    public partial class frmCargaCertificados : Form, View.IfrmCargaCertificados
    {
        public frmCargaCertificados()
        {
            InitializeComponent();
            var controller = new Controllers.frmCargaCertificadosController(this);
        }



        public string RFCEmisor
        {
            get { return txtRFC.Text; }
        }

        public String ArchivoCer
        {
            get { return txtCert.Text; }
        }

        public String ArchivoKey
        {
            get { return txtKey.Text; }
        }

        public string Password
        {
            get { return txtPwd.Text; }
        }

        public event EventHandler onCargaCertificados;


        public void ShowSessionError(Entity.SessionError error)
        {
            MessageBox.Show(String.Format("Status {0}: {1}", error.Status.ToString(), error.Description), "Ecodex UniTest");
        }

        public void ShowUnknownError(String message)
        {
            MessageBox.Show(String.Format("Error: {0}", message), "Ecodex UniTest");
        }


        private void btnCargar_Click(object sender, EventArgs e)
        {
            if (onCargaCertificados != null)
                onCargaCertificados(this, e);
        }

        private void btnCert_Click(object sender, EventArgs e)
        {
            if (FileCertificateDialog.ShowDialog() == DialogResult.OK)
            {                
                txtCert.Text = FileCertificateDialog.FileName;             
            }
        }

        private void btnKey_Click(object sender, EventArgs e)
        {
            if (FileKeyDialog.ShowDialog() == DialogResult.OK)
            {
                txtKey.Text = FileKeyDialog.FileName;
            }
        }
    }
}
